package com.lagou.service.impl;

import com.lagou.annotation.MyAutowire;
import com.lagou.annotation.MyService;
import com.lagou.annotation.MyTransactional;
import com.lagou.dao.AccountDao;
import com.lagou.service.AccountService;
import com.lagou.utils.ConnectionUtil;
import com.lagou.utils.TransactionManager;

import java.sql.Connection;
import java.sql.SQLException;

@MyService(value = "accountService", flag = true)
@MyTransactional("transactionManager")
public class AccountServiceImpl implements AccountService {

    @MyAutowire("accountDao")
    private AccountDao accountDao;

    @Override
    public void transfer(String from, String to, Double money) {

        accountDao.updateBalanceByUsername(from, money*-1);
//        int a = 1/0;
        accountDao.updateBalanceByUsername(to, money);

    }
}
